package com.jk.controller;

import com.jk.po.OrderPO;
import com.jk.service.OrderService;
import com.jk.vo.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/***
 * @ClassName: OrderController
 * @Description:TODO
 * @Auther: 景晨璇
 * @Date: 2021/6/30 15:07
 * @version : V1.0
 */
@RestController
@RequestMapping("order")
@Api("订单操作接口")
public class OrderController {
    //日志记录对象
    private static Logger logger = LoggerFactory.getLogger(OrderController.class);
    @Autowired
    private OrderService orderService;
    @GetMapping("queryorder")
    @ApiOperation("查询订单信息")
    public List<OrderPO> queryorder(){
        return orderService.queryOrder();
    }
    /**
    * @Author  王宇超
    * @method  queryOrderEnd
    * @description 查询已付款订单
    * @Date 17:05 2021/7/8
    * @Param  * @param
    * @return java.util.List<com.jk.po.OrderPO>
    **/
    @GetMapping("queryOrderEnd")
    @ApiOperation("查询已付款订单")
    public List<OrderPO> queryOrderEnd(){
        return orderService.queryOrderEnd();
    }


    @GetMapping("queryorderbyid/{id}")
    @ApiOperation("订单信息详情")
    public ResultInfo queryorderbyid(@PathVariable("id") @ApiParam("订单id") String id){
        ResultInfo resultInfo = null;
        try {
            resultInfo = orderService.queryOrderById(id);
            logger.info("订单详情成功");
        }catch (Exception e){
            logger.error("订单详情失败");
            resultInfo.setCode(500);
            resultInfo.setMessage("订单详情有误");
        }
        return resultInfo;
    }

   /**
    *
    *
    * @author 赵磊荣
    * @date 2021/7/8 10:48
    * @return redid未付款订单
    */
    @GetMapping("queryOrderRedis")
    @ApiOperation("redid未付款订单")
    public List<OrderPO>queryOrderRedis(){
        return orderService.queryOrderRedis();
    }
    /**
    * @Author 景晨璇
    * @method
    * @description 描述一下方法的作用
    * @Date 20:56 2021/7/8
    * @Param  * @param null
    * @return
    **/
    @GetMapping("orderRedis")
    public void orderRedis(){
        orderService.orderRedisMogdb();
    }
}
